/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Golf_Manager.vo;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class JoinMember implements Comparable {
    
    private String groupNm;
    private int groupRow = -1;
    private int groupCol = -1;
    private String memberSeq;
    private String name;
    private String birth;
    private String selectKey;
    private String score;
    
    public JoinMember(String memberSeq, String name, String birth) {
        this.memberSeq = memberSeq;
        this.name = name;
        this.birth = birth;
    }
    
    public JoinMember(String memberSeq, String name, String birth, String selectKey) {
        this.memberSeq = memberSeq;
        this.name = name;
        this.birth = birth;
        this.selectKey = selectKey;
    }

    public JoinMember(String groupNm, int groupRow, int groupCol, String memberSeq, String name, String birth) {
        this.groupNm = groupNm;
        this.groupRow = groupRow;
        this.groupCol = groupCol;
        this.memberSeq = memberSeq;
        this.name = name;
        this.birth = birth;
    }

    public JoinMember(String groupNm, int groupRow, int groupCol, String memberSeq, String name, String birth, String score) {
        this.groupNm = groupNm;
        this.groupRow = groupRow;
        this.groupCol = groupCol;
        this.memberSeq = memberSeq;
        this.name = name;
        this.birth = birth;
        this.score = score;
    }
    
    

    public String getGroupNm() {
        return groupNm;
    }

    public void setGroupNm(String groupNm) {
        this.groupNm = groupNm;
    }
    
    public int getGroupRow() {
        return groupRow;
    }

    public void setGroupRow(int groupRow) {
        this.groupRow = groupRow;
    }

    public int getGroupCol() {
        return groupCol;
    }

    public void setGroupCol(int groupCol) {
        this.groupCol = groupCol;
    }
    
    public String getMemberSeq() {
        return memberSeq;
    }

    public void setMemberSeq(String memberSeq) {
        this.memberSeq = memberSeq;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBirth() {
        return birth;
    }

    public void setBirth(String birth) {
        this.birth = birth;
    }

    public String getSelectKey() {
        return selectKey;
    }

    public void setSelectKey(String selectKey) {
        this.selectKey = selectKey;
    }

    public String getScore() {
        return score;
    }

    public void setScore(String score) {
        this.score = score;
    }
  
    @Override
    public int compareTo(Object o) {
        int cGroupRow = ((JoinMember)o).getGroupRow();
        int cGroupCol = ((JoinMember)o).getGroupCol();
        
        if(getGroupRow() != cGroupRow ){
            return getGroupRow() - cGroupRow;
        } else {
            return getGroupCol() - cGroupCol;
        }
    }
    
    @Override
	public String toString() {
		Class cls = this.getClass();
		Method[] arrMethod = cls.getMethods();
		StringBuilder sb = new StringBuilder(this.getClass().toString());
		sb.append(" => ");
		
		try {
			for(Method m : arrMethod) {
				if(m.getName().startsWith("get") && !m.getName().equals("getClass")) { 
					sb.append(m.getName());
					sb.append(": ");
					sb.append(m.invoke(this));
					sb.append(", ");
				}
			}
		} catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {
			Logger.getLogger(Member.class.getName()).log(Level.SEVERE, null, e);
		}
		
		return sb.toString().substring(0, sb.length() - 2);
	}
}
